﻿using System;
using System.Diagnostics;
using System.Linq;
using Soundteller.AudioVisual.Services.Interfaces;
using Soundteller.Visual.Repositories.Interfaces;
using Soundteller.Visual.Services.Interfaces;
using Soundteller.Audio.Repositories.Interfaces;
using Soundteller.AudioVisual.Repositories.Interfaces;
using Soundteller.Visual.Model;
using System.Collections.Generic;

namespace Soundteller.AudioVisual.Services
{
    public class SoundtellerDrawer : ISoundtellerDrawer
    {
        private readonly IDrawer _drawer;
        private readonly IGraphicRepository _graphicRepository;
        private readonly ISoundBufferRepository _soundBufferRepository;
        private readonly IPadRepository _padRepository;

        public SoundtellerDrawer(IDrawer drawer, IGraphicRepository graphicRepository)
        {
            if (drawer == null) throw new ArgumentNullException("drawer");
            if (graphicRepository == null) throw new ArgumentNullException("graphicRepository");

            _drawer = drawer;
            _graphicRepository = graphicRepository;
        }

        public void Draw()
        {
            Debug.WriteLine("{0}.Draw()", GetType());

            var graphics = _graphicRepository.GetByCategory("Soundteller");
            if (!graphics.Any())
                throw new InvalidOperationException("Cannot draw pad surface, graphics not found");

            _drawer.Draw(graphics);
        }
    }
}